﻿<inter:PluginConfigForm x:Class="Convertor.Plugin.Encrypt.ConfigForm"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:inter="clr-namespace:Convertor.Interface;assembly=Convertor.Interface"
             xmlns:sm="clr-namespace:Wpf.CommonTools.SystemExtension;assembly=Wpf.CommonTools"
             xmlns:conv="clr-namespace:Wpf.CommonTools.Converter;assembly=Wpf.CommonTools"
             xmlns:local="clr-namespace:Convertor.Plugin.Encrypt"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             mc:Ignorable="d" 
             d:DesignWidth="300">
    <inter:PluginConfigForm.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Convertor;component\Assets\Style.xaml"/>
                <ResourceDictionary Source="Assets\Lang\StringResource.zh.xaml"/>
                <ResourceDictionary Source="Assets\Lang\StringResource.en.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <ObjectDataProvider x:Key="EncryptTypes" 
                        MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="local:EncryptTypes"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
            <ObjectDataProvider x:Key="DirectionTypes" 
                        MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="local:DirectionTypes"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
            <conv:EnumToVsibleConverter x:Key="EnumToVsibleConverter"/>
            <conv:FindUILanguageConverter x:Key="FindUILanguageConverter"/>
        </ResourceDictionary>
    </inter:PluginConfigForm.Resources>
    <DockPanel>
        <AdornerDecorator DockPanel.Dock="Top">
            <ComboBox x:Name="cbEncryptType"
                      ItemsSource="{Binding Source={StaticResource EncryptTypes}}"
                      SelectedItem="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type inter:PluginConfigForm}}, Path=Config.EncryptType, UpdateSourceTrigger=PropertyChanged}">
                <sm:WatermarkService.Titlemark>
                    <TextBlock Text="{DynamicResource Plugin_Encrypt_EncryptType}" TextAlignment="Right"></TextBlock>
                </sm:WatermarkService.Titlemark>
            </ComboBox>
        </AdornerDecorator>
        <AdornerDecorator DockPanel.Dock="Top">
            <ComboBox x:Name="cbEncodingList" ItemsSource="{Binding Path=EncodingList, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type inter:PluginConfigForm}}}"
                                      SelectedItem="{Binding Path=Config.EncodingContent, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type inter:PluginConfigForm}}, UpdateSourceTrigger=PropertyChanged}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=DisplayName}"></TextBlock>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
                <sm:WatermarkService.Titlemark>
                    <TextBlock Text="{DynamicResource Plugin_Encrypt_Encoding}" TextAlignment="Right"></TextBlock>
                </sm:WatermarkService.Titlemark>
            </ComboBox>
        </AdornerDecorator>
        <AdornerDecorator DockPanel.Dock="Top">
            <AdornerDecorator.Visibility>
                <Binding Path="SelectedValue" ElementName="cbEncryptType" Converter="{StaticResource EnumToVsibleConverter}">
                    <Binding.ConverterParameter>
                        <sys:Int32>66</sys:Int32>
                    </Binding.ConverterParameter>
                </Binding>
            </AdornerDecorator.Visibility>

            <ComboBox x:Name="cbDirection"
                      ItemsSource="{Binding Source={StaticResource DirectionTypes}}"
                      SelectedItem="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type inter:PluginConfigForm}}, Path=Config.SymmetricType, UpdateSourceTrigger=PropertyChanged}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=., Converter={StaticResource FindUILanguageConverter}, ConverterParameter='Plugin_Encrypt_'}"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
                <sm:WatermarkService.Titlemark>
                    <TextBlock Text="{DynamicResource Plugin_Encrypt_Direction}" TextAlignment="Right"></TextBlock>
                </sm:WatermarkService.Titlemark>
            </ComboBox>
        </AdornerDecorator>
        <AdornerDecorator DockPanel.Dock="Top" 
                          Visibility="{Binding ElementName=cbEncryptType, Path=SelectedValue, Converter={StaticResource EnumToVsibleConverter}, ConverterParameter={x:Static local:EncryptTypes.Symmetric}}">
            <TextBox Text="{Binding Path=Config.Key, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type inter:PluginConfigForm}}, UpdateSourceTrigger=PropertyChanged}">
                <sm:WatermarkService.Titlemark>
                    <TextBlock Text="{DynamicResource Plugin_Encrypt_Key}" TextAlignment="Right"></TextBlock>
                </sm:WatermarkService.Titlemark>
            </TextBox>
        </AdornerDecorator>
        <TextBlock Style="{StaticResource InfoStyle}" DockPanel.Dock="Top" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type inter:PluginConfigForm}}, Path=Config.ToolTip}"/>
    </DockPanel>
</inter:PluginConfigForm>
